package com.findFish.water.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.water.domain.FarmLocation;
import com.findFish.water.service.IFarmLocationService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 养殖场地理信息Controller
 * 
 * @author admin
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/water/location")
public class FarmLocationController extends BaseController
{
    @Autowired
    private IFarmLocationService farmLocationService;

    /**
     * 查询养殖场地理信息列表
     */
    @PreAuthorize("@ss.hasPermi('water:location:list')")
    @GetMapping("/list")
    public TableDataInfo list(FarmLocation farmLocation)
    {
        startPage();
        List<FarmLocation> list = farmLocationService.selectFarmLocationList(farmLocation);
        return getDataTable(list);
    }

    /**
     * 导出养殖场地理信息列表
     */
    @PreAuthorize("@ss.hasPermi('water:location:export')")
    @Log(title = "养殖场地理信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FarmLocation farmLocation)
    {
        List<FarmLocation> list = farmLocationService.selectFarmLocationList(farmLocation);
        ExcelUtil<FarmLocation> util = new ExcelUtil<FarmLocation>(FarmLocation.class);
        util.exportExcel(response, list, "养殖场地理信息数据");
    }

    /**
     * 获取养殖场地理信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('water:location:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(farmLocationService.selectFarmLocationById(id));
    }

    /**
     * 新增养殖场地理信息
     */
    @PreAuthorize("@ss.hasPermi('water:location:add')")
    @Log(title = "养殖场地理信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FarmLocation farmLocation)
    {
        return toAjax(farmLocationService.insertFarmLocation(farmLocation));
    }

    /**
     * 修改养殖场地理信息
     */
    @PreAuthorize("@ss.hasPermi('water:location:edit')")
    @Log(title = "养殖场地理信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FarmLocation farmLocation)
    {
        return toAjax(farmLocationService.updateFarmLocation(farmLocation));
    }

    /**
     * 删除养殖场地理信息
     */
    @PreAuthorize("@ss.hasPermi('water:location:remove')")
    @Log(title = "养殖场地理信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(farmLocationService.deleteFarmLocationByIds(ids));
    }
}
